package com.ias.train.service.impl;

import com.ias.train.dao.UserMapper;
import com.ias.train.entity.UserInfo;
import com.ias.train.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

/**
 * @program: train
 * @description: 用户服务类
 * @author: Daniel Shen
 * @create: 2022-04-23 15:15
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public UserInfo add(UserInfo userInfo) {
        userInfo.setUserId(String.valueOf(UUID.randomUUID()));
        userMapper.insert(userInfo);
        return userInfo;
    }

    @Override
    public UserInfo edit(UserInfo userInfo) {
        userMapper.update(userInfo);
        return userInfo;
    }

    @Override
    public UserInfo delete(UserInfo userInfo) {
        userMapper.delete(userInfo);
        return userInfo;
    }

    @Override
    public UserInfo getOneUser(UserInfo userInfo) {
        return userMapper.select(userInfo);
    }

    @Override
    public List<UserInfo> getUsers(UserInfo userInfo) {
        return userMapper.selectCollection(userInfo);
    }
}
